package com.wangxiang.shop.product.uniapp;

import com.wangxiang.common.utils.R;
import com.wangxiang.common.utils.UniParamEntity;
import com.wangxiang.shop.product.entity.SpuEntity;
import com.wangxiang.shop.product.entity.UniShopEntity;
import com.wangxiang.shop.product.service.UniShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("uni")
public class UniShopController {
    @Autowired
    private UniShopService uniShopService;

    /**
     * 前端首页通过tabnacv获取商品数据
     * @param map
     * @return
     */
    @RequestMapping("getSpuByTab")
    public R getSpuInIndexNav(@RequestBody HashMap<String,String> map){
        List<SpuEntity> list = uniShopService.getSpuInIndex(map.get("tab"));
        return R.ok().put("list",list);

    }
    @RequestMapping("getShop")
    public R getSpu(@RequestBody HashMap<String, Integer> map){
        SpuEntity shop = uniShopService.getShop(map.get("id"));
        return R.ok().put("data",shop);
    }




}
